package com.hyx.nettystudy;

import com.hyx.nettystudy.discard.HttpRequestHandler;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @ClassName HttpServerInitializer
 * @Description TODO
 * @Author 黄乙轩
 * @Date 2021/11/17 17:00
 * @Version 1.0
 **/

public class HttpServerInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();
        pipeline.addLast(new HttpServerCodec());
        pipeline.addLast("httpAggregator", new HttpObjectAggregator(512*1024));
        pipeline.addLast(new HttpRequestHandler());
    }
}
